﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Threading.Tasks;
using CeskyRozhlasWP8.Model;

namespace CeskyRozhlasWP8.ViewModel
{
    public class RadioStationPageViewModel : BaseViewModel
    {

        public RadioStationPageViewModel()
        {
            if (DesignerProperties.IsInDesignTool)
                return;
        }

        private ObservableCollection<DetailedScheduleItem> _currentSchedule = new ObservableCollection<DetailedScheduleItem>();
        public ObservableCollection<DetailedScheduleItem> CurrentSchedule
        {
            get { return _currentSchedule; }
            set { SetField(ref _currentSchedule, value); }
        }

        public async Task RefetchStationDetails(int iStationId)
        {
            //|| iStationId != _radioStationPageVm.CurrentStation.Id
            if (CurrentStation == null )
            {
                CurrentStation = await ShowsData.Instance.GetStationById(iStationId);
                CurrentSchedule.Clear();
                foreach (
                    var stationInfo in
                        await
                            ShowsData.Instance.GetScheduleForStation(iStationId))
                {
                    CurrentSchedule.Add(stationInfo);
                }
            }
        }


        private ShortStationDescription _currentStation;
        public ShortStationDescription CurrentStation
        {
            get { return _currentStation; }
            set { SetField(ref _currentStation, value); }
        }


    }
}